<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
<body>
	<ui:composition>
		<p:dialog header="PO Request Detail" widgetVar="#{dialogWidgetName}"
			modal="true" showEffect="fade" hideEffect="fade" resizable="false">
			<p:outputPanel id="poRequestDetail" style="text-align:center;">
				<p:panelGrid
					rendered="#{not empty dtPurchaseOrderRequestView.selectedItem}" >
					<f:facet name="header">
						<p:row>
							<p:column>Description</p:column>
							<p:column>Brand</p:column>
							<p:column>Part Number</p:column>
							<p:column>Unit</p:column>
							<p:column>Remaining Qty</p:column>
						</p:row>
					</f:facet>
						<p:row>
							<p:column><h:outputText value="#{dtPurchaseOrderRequestView.selectedItem.description}" /></p:column>
							<p:column><h:outputText value="#{dtPurchaseOrderRequestView.selectedItem.brand}" /></p:column>
							<p:column><h:outputText value="#{dtPurchaseOrderRequestView.selectedItem.partNumber}" /></p:column>
							<p:column><h:outputText value="#{dtPurchaseOrderRequestView.selectedItem.unit}" /></p:column>
							<p:column><h:outputText value="#{dtPurchaseOrderRequestView.maxQty}" /></p:column>
						</p:row>
				</p:panelGrid>
				<br/>
				<p:panelGrid
					rendered="#{dtPurchaseOrderRequestView.renderDialog}" >
					<f:facet name="header">
						<p:row>
							<p:column>Supplier</p:column>
							<p:column>Quantity</p:column>
							<p:column>Price per Unit</p:column>
							<p:column>Action</p:column>
						</p:row>
					</f:facet>
					<p:row>
						<p:column>
							<p:selectOneMenu id="supplier" value="#{dtPurchaseOrderRequestView.supplierId}"
							 	filter="true" filterMatchMode="contains"
								 required="true" requiredMessage="Please select supplier">
								 <p:ajax listener="#{dtPurchaseOrderRequestView.supplierHasChanged}" update="poRequestDetail"/>
								 <f:selectItems value="#{dtPurchaseOrderRequestView.suppliers}" />
							</p:selectOneMenu>
							<br/><h:message for="supplier" /> 
						</p:column>
						<p:column>
							<p:spinner id="qtyOrder" value="#{dtPurchaseOrderRequestView.qtyOrder}" min="1" max="#{dtPurchaseOrderRequestView.maxQty}">
							</p:spinner>
							<br/><h:message for="qtyOrder" />
						</p:column>
						<p:column>
							<p:inputText id="unitPrice" label="Price" 
								value="#{dtPurchaseOrderRequestView.unitPrice}">
								<f:validateDoubleRange minimum="0.1" maximum="999999999.99" />
							</p:inputText>
							<br/><h:message for="unitPrice" />
						</p:column>
						<p:column>
							<!-- update=":poReqForm @form"  -->
							<p:commandButton value="Place Order"
								ajax="false" update=":poReqDlgForm:poRequestDetail :poAccordion" 
								action="#{dtPurchaseOrderRequestView.placeOrder}" />
							<br/><br/>
        					<p:selectBooleanCheckbox id="cb" value="#{dtPurchaseOrderRequestView.saveSupplierPrice}" />
							<h:outputText value=" Save Supplier Price" />
						</p:column>
					</p:row>
				</p:panelGrid>
				
				<p:panelGrid
					rendered="#{not dtPurchaseOrderRequestView.renderDialog}" >
					<h3>Purchase Order Disabled</h3>
					<h4>Purchase Requisition not in APPROVED or INPROGRESS status</h4>
				</p:panelGrid>

			</p:outputPanel>
		</p:dialog>
	</ui:composition>
</body>
</html>